package com.journey.org.app

import kotlinx.coroutines.Deferred
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.*

/**
 * 新类型的HttpAPI
 */
interface HttpAPI {

    @FormUrlEncoded
    @POST
    fun <T> postFormAsync(
        @Url url: String,
        @FieldMap(encoded = true) paramMap: Map<String, @JvmSuppressWildcards Any>
    ): @JvmSuppressWildcards Deferred<BaseResponse<T>>

    @POST
    fun <T> postJsonAsync(@Url url: String?, @Body body: RequestBody): Deferred<BaseResponse<T>>

    @GET
    fun <T> getAsync(
        @Url url: String?,
        @QueryMap paramMap: Map<String, Any>
    ): Deferred<BaseResponse<T>>

    @GET
    fun <T> getAsync(@Url url: String): Deferred<BaseResponse<T>>

    @POST
    fun <T> uploadPhotoFileAsync(
        @Url url: String,
        @Body body: MultipartBody
    ): Deferred<BaseResponse<T>>
}